package com.xxx.file;

import java.io.FileReader;
import java.io.IOException;
import java.sql.Array;

/**
 * @version v1.0
 * @Description
 * @Author admin
 * @date 2021/7/22  14:06
 * @Copyright
 */
public class fileReaderDome {
    public static void main(String[] args) {

        m1();

        try ( FileReader fileReader = new FileReader("a.txt")){
            int i = 0;//读到的字符数

            while ((i = fileReader.read()) !=-1){
                System.out.println((char) i);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }




    }

    private static void m1() {
        try ( FileReader fileReader = new FileReader("a.txt")){
            int i = 0;//读到的字符数
            char[] cbuf= new char[1024];
            while ((i = fileReader.read(cbuf)) !=-1){
               // System.out.println(cbuf);
                String s = new String(cbuf, 0, i);
                System.out.println(s);
            }
            fileReader.read(cbuf );
            System.out.println();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
